﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package com.facebook.graph.core {
    import flash.net.*;
    import flash.utils.*;
    import com.facebook.graph.net.*;
    import com.facebook.graph.data.*;

    public class AbstractFacebook {

        protected var session:FacebookSession;
        protected var openRequests:Dictionary;

        public function AbstractFacebook():void{
            openRequests = new Dictionary();
        }
        protected function deleteObject(_arg1:String, _arg2:Function=null):void{
            var _local3:Object = {method:"delete"};
            api(_arg1, _arg2, _local3, URLRequestMethod.POST);
        }
        protected function fqlQuery(_arg1:String, _arg2:Function):void{
            callRestAPI("fql.query", _arg2, {query:_arg1});
        }
        protected function callRestAPI(_arg1:String, _arg2:Function=null, _arg3=null, _arg4:String="GET"):void{
            if (_arg3 == null){
                _arg3 = {};
            };
            _arg3.format = "json";
            if (session != null){
                _arg3.access_token = session.accessToken;
            };
            var _local5:FacebookRequest = new FacebookRequest(FacebookURLDefaults.API_URL, _arg4);
            openRequests[_local5] = _arg2;
            _local5.call(("/method/" + _arg1), _arg3, handleRequestLoad);
        }
        protected function getImageUrl(_arg1:String, _arg2:String=null):String{
            return (((((FacebookURLDefaults.GRAPH_URL + "/") + _arg1) + "/picture") + ((_arg2)!=null) ? ("?type=" + _arg2) : ""));
        }
        protected function api(_arg1:String, _arg2:Function=null, _arg3=null, _arg4:String="GET"):void{
            _arg1 = ((_arg1.indexOf("/"))!=0) ? ("/" + _arg1) : _arg1;
            if (session != null){
                if (_arg3 == null){
                    _arg3 = {};
                };
                _arg3.access_token = session.accessToken;
            };
            var _local5:FacebookRequest = new FacebookRequest(FacebookURLDefaults.GRAPH_URL, _arg4);
            openRequests[_local5] = _arg2;
            _local5.call(_arg1, _arg3, handleRequestLoad);
        }
        protected function handleRequestLoad(_arg1:FacebookRequest):void{
            var _local3:Object;
            var _local2:Function = openRequests[_arg1];
            if (_local2 === null){
                delete openRequests[_arg1];
            };
            if (_arg1.success){
                _local3 = (("data" in _arg1.data)) ? _arg1.data.data : _arg1.data;
                _local2(_local3, null);
            } else {
                _local2(null, _arg1.data);
            };
            delete openRequests[_arg1];
        }

    }
}//package com.facebook.graph.core 
